﻿using Mengsk.ProxyDelivery.Print.Domain;
using Mengsk.ProxyDelivery.Print.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace Mengsk.ProxyDelivery.Print.ViewModels
{
    class PrintTemplateItemViewModelForDate : PrintTemplateItemViewModelCommon
    {
        protected override void OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e)
        {
            if (e.Property == PrintTemplateItemViewModelCommon.FormatProperty)
            {
                try
                {
                    this.PreviewValue = DateTime.Now.ToString(e.NewValue.ToString());
                }
                catch
                {
                    MessageBox.Show("请输入合法的时间格式");
                }
            }

            base.OnPropertyChanged(e);
        }

        public PrintTemplateItemViewModelForDate(PrintTemplate template)
            : base(template)
        {
            this.PropertyUI = new PrintTemplateItemDateUserControl();
            this.PropertyUI.DataContext = this;
            this.Format = "yyyy MM dd";
        }
    }
}
